<template>
  <div id="login">
  
    <ul class="menu_top_list ">
            <router-link tag="li" to="/home"><span>返回</span></router-link>
            <li>用户登录</li>
            <li></li>
        </ul>
    <div class="toMy">
      <div class="logo">
          <img src="https://rs.sfacg.com/web/novel/images/images/logo_color.png" alt="">
      </div>
      <van-form @submit="onSubmit">
        <van-field v-model="username" name="用户名" label="用户名" placeholder="用户名"   :rules="[{ required: true, message: '请填写用户名' }]">
        </van-field>
        <van-field v-model="password" type="password" name="密码" label="密码" placeholder="密码" :rules="[{ required: true, message: '请填写密码' }]" />
        <div style="margin: 16px;">
          <van-button round block type="info" native-type="submit" class="sub" id="Login" >登 &nbsp;&nbsp;录</van-button>
        </div>
      </van-form>
    </div>
   

  </div>
</template>

<script>
import { Toast } from 'vant';
export default {
  data() {
    return {
      username: "",
      password: "",
     
    };
  },

  mounted() {},

  methods: {
    onSubmit(values) {
      console.log("submit", values);
      var Usename = /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/;
      if(Usename.test(this.username)){
       
        localStorage.setItem('userName',this.values);
       
      
        this.$router.push("/my")
      }else{
         
          Toast("请输入正确的格式")
      }

    console.log(this.username);

   
 




    },
  
    
  
  },
  
};
</script>

<style lang="scss">
#login{
    .logo{
        padding-top: 100px;
        padding-bottom: 40px;
        display: flex;
        justify-content: center;
        width: 100%;
        img{
            width: 50%;
        }
    }
}
.toMy{
margin-top: 12px;
 padding:0 11.7px 
}
.sub{
  background-color: #EF9965;
  border: 0;
}
</style>